package com.example.hosrxjavaapplication.slice;

import com.example.hosrxjavaapplication.ResourceTable;
import com.example.hosrxjavaapplication.inject.InjectUtils;
import com.example.hosrxjavaapplication.inject.SliceInjectViewClick;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        InjectUtils.inject(this);
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

    @SliceInjectViewClick({ResourceTable.Id_startRx})
    public void onClick(Component component) {
        Intent secondIntent = new Intent();
        // 指定待启动FA的bundleName和abilityName
        Operation operation = new Intent.OperationBuilder()
                .withDeviceId("")
                .withBundleName("com.example.hosrxjavaapplication")
                .withAbilityName("com.example.hosrxjavaapplication.RxJavaAbility")
                .build();
        secondIntent.setOperation(operation);
        // 通过AbilitySlice的startAbility接口实现启动另一个页面
        startAbility(secondIntent);
    }

}
